package st.yushao.restaurant.action.custom;

import org.apache.struts2.json.annotations.JSON;

import com.opensymphony.xwork2.ActionContext;

import st.yushao.restaurant.dao.TableDaoService;
import st.yushao.restaurant.fw.AbstractBaseAction;
import st.yushao.restaurant.vo.TableVO;

public class SelectTable extends AbstractBaseAction {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 5174002918739593581L;
    private int tableId;
    private TableDaoService ts;
    private TableVO table;

    @JSON(name="table", serialize=false)
    public TableVO getTable() {
        return table;
    }

    public void setTable(TableVO table) {
        this.table = table;
    }

    @JSON(name="tableId")
    public int getTableId() {
        return tableId;
    }

    public void setTableId(int tableId) {
        this.tableId = tableId;
    }

    public void setTs(TableDaoService ts) {
        this.ts = ts;
    }

    public String doExecute() {
        this.table = ts.getTablesByTableId(tableId);
        ActionContext ac = ActionContext.getContext();
        if (table != null) {
            ac.getSession().put(KEYS.CUR_TABLE_KEY, table);
        }
        return SUCCESS;
    }
}
